<template>
  <div class="doctorregister">
    <div class="container ">
      <!-- 头部信息 -->
      <header>
      <Row>
        <Col :xs="24">
          <div class="margin-up-down">
            <fourLevelLinkage
              @changeProvince="changeProvince"
              @changeCity="changeCity"
              @changeArea="changeArea"
              @changeHospital="changeHospital"
              :province="province"
              :city="city"
              :area="area"
              :hospital="hospital"
              :hospitalType="1"
            ></fourLevelLinkage>
          </div>
          <div class="margin-up-down">
            <Button type="primary" icon="ios-search" @click="getSuperviseData(1)"></Button>
          </div>
        </Col>
      </Row>  
      </header>   
      <!-- 列表 -->
      <div class="list">
        <Table @on-selection-change="selectChange" :loading="tableLoading" border stripe :columns="columns1" :data="list"></Table>
      </div>
    </div>
    <!--分页器-->
    <div class="page">
      <Page :total="superviseListSize" :current='pageNo' :page-size="pageSize" show-total show-elevator @on-change="pageChange"/>
    </div>
  </div>
</template>
<script>
// 医生注册信息
import cookie from "@/utils/cookie.js";
import api from "@/api/commonApi";
import fourLevelLinkage from "@/components/fourLevelLinkage";
export default {
  components: {
    fourLevelLinkage
  },
  data() {
    return {
      tableLoading: false,
      province: null,
      city: null,
      area: null,
      hospital: null,
      selections: [],
      superviseListSize: 0,
      list: [],
      pageNo: 1,
      pageSize: 10,
      columns1: [
        {title: "排序",key: "sum",width: 80,align: "center",
          render: (h, params) => {
              let sum = (this.pageNo-1)*this.pageSize + params.index +1;
              return h("span", sum);
          }
        },
        {title: "机构名称",key: "orgName",align: "center"},
        {title: "机构第二名称",key: "orgSecondName",align: "center"},
        {title: "机构负责人",key: "linkman",align: "center"},
        {title: "健康咨询",key: "type2",align: "center",
            render: (h, params) => {
                let row = params.row;
                return h("div", [ 
                    h(
                    "span",
                    {
                        props: {
                        size: "small"
                        },
                        style: {
                            color: '#5362e1',
                            margin: "0px 6px"
                        },
                        on: {
                        click: () => {
                            this.handleChargeReview(row);
                        }
                        }
                    },
                    row.type2
                    )
                ]);
            }
        },
        {
          title: "巡诊",key: "type1",align: "center", 
            render: (h, params) => {
                let row = params.row;
                return h("div", [ 
                    h(
                    "span",
                    {
                        props: {
                        size: "small"
                        },
                        style: {
                            color: '#5362e1',
                            margin: "0px 6px"
                        },
                        on: {
                        click: () => {
                            this.handleChargeReview(row);
                        }
                        }
                    },
                    row.type1
                    )
                ]);
            }
        },
        {title: "检查项目",key: "type3",align: "center",
            render: (h, params) => {
                let row = params.row;
                return h("div", [ 
                    h(
                    "span",
                    {
                        props: {
                        size: "small"
                        },
                        style: {
                            color: '#5362e1',
                            margin: "0px 6px"
                        },
                        on: {
                        click: () => {
                            this.handleChargeReview(row);
                        }
                        }
                    },
                    row.type3
                    )
                ]);
            }
        },
        {title: "检验项目",key: "type4",align: "center",
            render: (h, params) => {
                let row = params.row;
                return h("div", [ 
                    h(
                    "span",
                    {
                        props: {
                        size: "small"
                        },
                        style: {
                            color: '#5362e1',
                            margin: "0px 6px"
                        },
                        on: {
                        click: () => {
                            this.handleChargeReview(row);
                        }
                        }
                    },
                    row.type4
                    )
                ]);
            }
        },               
        {title: "治疗项目",key: "type5",align: "center",
            render: (h, params) => {
                let row = params.row;
                return h("div", [ 
                    h(
                    "span",
                    {
                        props: {
                        size: "small"
                        },
                        style: {
                            color: '#5362e1',
                            margin: "0px 6px"
                        },
                        on: {
                        click: () => {
                            this.handleChargeReview(row);
                        }
                        }
                    },
                    row.type5
                    )
                ]);
            }
        },               
        {title: "其他",key: "type6",align: "center",
            render: (h, params) => {
                let row = params.row;
                return h("div", [ 
                    h(
                    "span",
                    {
                        props: {
                        size: "small"
                        },
                        style: {
                            color: '#5362e1',
                            margin: "0px 6px"
                        },
                        on: {
                        click: () => {
                            this.handleChargeReview(row);
                        }
                        }
                    },
                    row.type6
                    )
                ]);
            }
        },               
        {title: "设立科室",key: "type7",align: "center",
            render: (h, params) => {
                let row = params.row;
                return h("div", [ 
                    h(
                    "span",
                    {
                        props: {
                        size: "small"
                        },
                        style: {
                            color: '#5362e1',
                            margin: "0px 6px"
                        },
                        on: {
                        click: () => {
                            this.handleDeptReview(row);
                        }
                        }
                    },
                    row.type7
                    )
                ]);
            }
        },
      ],
    };
  },
  created() {
    let breadList = [
      { path: "/index", title: "首页" },
      {
        path: "/index/maintain/indexManagement/index",
        title: "索引管理"
      },
      {
        path: "/index/supervision/qualificationApply/list",
        title: "资质申请"
      }
    ];
    this.$emit("changeBreadList", breadList);
  },
  mounted() {
    let pageNo = this.$route.query.pageNo;
    if (pageNo) {
      this.pageNo = pageNo;
    }
    this.getSuperviseData(this.pageNo);
  },
  methods: {
    changeProvince(val) {
      this.province = val;
    },
    changeCity(val) {
      this.city = val;
    },
    changeArea(val) {
      this.area = val;
    },
    changeHospital(val) {
      this.hospital = val;
    },
    selectChange(selections) {
        this.selections = selections;
    },
    //收费项目列表
    handleChargeReview(item) {
        console.log(11222222)
      this.functionJS.queryNavgationTo(
        this,
        "/index/supervision/treatmentSupervision/chargeList",
        {
          pageNo: this.pageNo,
          hospitalId: item.hospitalId,
          orgName: item.orgName,
        }
      );
    },
    //科室列表
    handleDeptReview(item) {
        this.functionJS.queryNavgationTo(
        this,
        "/index/supervision/treatmentSupervision/deptList",
        {
          pageNo: this.pageNo,
          hospitalId: item.hospitalId,
          orgName: item.orgName,
        }
      );
    },
    // 分页
    pageChange(index) {
      this.getSuperviseData(index);
    },
    // 获取页面数据
    getSuperviseData(pageNo) {
      if  (pageNo) {
        this.pageNo = Number(pageNo);
      }
      let params = {
        pageNo: this.pageNo,
        pageSize: this.pageSize,
        // reviewStatus: 2,
      };
      params.provinceCode = this.province ? this.province : null;
      params.cityCode = this.city ? this.city : null;
      params.areaCode = this.area ? this.area : null;
      params.hospitalId = this.hospital ? this.hospital : null;
      this.tableLoading = true;
      this.$axios.post(api.findSuperviseItemList, params).then(res => {
        if (res.data.code) {
          let ret = res.data.object;
          this.superviseListSize = ret.total;
          if(ret.records){
            ret.records.forEach((item, index) => {
              item.sum = this.addZeros(index);
            });           
            this.list = ret.records;
          } else {
            this.list = []
          }
        } else {
          this.$Message.info(res.data.message);
        }
        this.tableLoading = false;
      }).catch(() => {
        this.tableLoading = false;
      });
    }
  },
  watch: {
    'pageSize'(nv, ov) {
        this.getSuperviseData(this.pageNo)
    },
  }
};
</script>
<style lang="less" scoped>
.doctorregister {
  padding: 10px;
  width: 100%;
  background: #ffffff;
  box-sizing: border-box;
  margin: 0 auto;
  .margin-up-down {
        display: inline-block;
        margin: 10px 0;
    }
    .addButton{
      border: 1px solid #21c780;
      background-color: #21c780;
    }
  .container {
    width: 100%;
    margin: 0 auto;
    header {
      width: 100%;
      position: relative;
      .search{
        margin: 10px 0;
      }
      
    }
    .list {
      width: 100%;
      margin: 10px 0;
    }
  }
  .page{
      text-align: center;
    }
}
</style>